stages:
  - build
  - upload
  - deploy

build:
  stage: build
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
  script:
    - docker build -t afisha:$CI_COMMIT_SHORT_SHA .

upload:
  stage: upload
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
  script:
    - kind load docker-image afisha:$CI_COMMIT_SHORT_SHA

deploy:
  stage: deploy
  environment:
    name: production
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
  script:
    - kubectl create configmap afisha-conf --from-file=manifests/ --namespace=default -o yaml --dry-run=client | kubectl apply -f -
    - kubectl set image deployment/afisha-deployment afisha=afisha:$CI_COMMIT_SHORT_SHA
